<template>
  <div id="bacTestResult">
    <vxe-toolbar class-name="bg-grey light">
      <template #buttons>
        <!-- <vxe-button type="text" class="button-blue margin-lr-xs" :content="'上一个'" @click="prevCLick()"></vxe-button>
        <vxe-button type="text" class="button-blue margin-lr-xs" :content="'下一个'" @click="nextCLick()"></vxe-button> -->
        <vxe-button type="text" class="button-blue margin-lr-xs" :content="'保存'"></vxe-button>
        <vxe-button type="text" class="button-blue margin-lr-xs" :content="'标签补打'"></vxe-button>
        <!-- <vxe-button type="text" class="button-blue margin-lr-xs" :content="'查看病历'"></vxe-button> -->
      </template>
    </vxe-toolbar>
    <el-tabs v-model="activeName" type="card" class="lab-bac-test-result-tab el-tab-sm" @tab-click="tabHandleClick">
      <el-tab-pane label="观察结果" name="first"></el-tab-pane>
      <el-tab-pane label="过程记录" name="second">过程记录</el-tab-pane>
      <el-tab-pane label="流程单" name="third">流程单</el-tab-pane>
      <el-tab-pane label="申请项目" name="fourth"></el-tab-pane>
    </el-tabs>
    <Splitpanes horizontal v-if="activeName === 'first'" :dbl-click-splitter="false" style="height:calc(100% - 160px)">
      <Pane :size="paneTopSize">
        <Splitpanes :dbl-click-splitter="false">
          <Pane size="70">
            <Splitpanes horizontal :dbl-click-splitter="false">
              <Pane size="50">
                <div style="height: calc(100%)">
                  <vxe-table ref="bacDrugTestResultRef" height="auto" border show-overflow :header-cell-style="setBacDrugTestResultHeaderCellStyle" :data="bacDrugTestResult" :row-config="{ isCurrent: true }" :column-config="{ resizable: true }" :edit-config="{ trigger: 'click', mode: 'cell', showIcon: false }" @edit-closed="bacDrugTestResultEditClose">
                    <vxe-column type="seq" width="30"></vxe-column>
                    <vxe-column field="isReport" title="操作" align="center" :edit-render="{}" width="60">
                      <template #edit="{ row }">
                        <vxe-checkbox v-model="row.isReport" :checked-value="1" :unchecked-value="0"></vxe-checkbox>
                      </template>
                      <template #default="{ row }">
                        <vxe-checkbox v-model="row.isReport" :checked-value="1" :unchecked-value="0"></vxe-checkbox>
                      </template>
                    </vxe-column>
                    <vxe-column field="antRecomGroupNa" title="培养瓶" :edit-render="{ autofocus: '.vxe-input--inner' }" min-width="120px">
                      <template #default="{ row }">
                        <span>{{ row.antRecomGroupNa }}</span>
                      </template>
                      <template #edit="{ row }">
                        <vxe-input v-model="row.isReport" type="text"></vxe-input>
                      </template>
                    </vxe-column>
                    <vxe-column field="antNa" title="容器条码" :edit-render="{ autofocus: '.vxe-input--inner' }" width="110">
                      <template #default="{ row }">
                        <span>{{ row.antNa }}</span>
                      </template>
                      <template #edit="{ row ,rowIndex}">
                        <VxePulldownSelectionByDictType :isChild="true" :childIndex="rowIndex" :isPage="false" :displayTexts="['antName']" :displayTextObj="row.antNa?row.antNa:''" :tableColumn="[{ title: '#', type: 'seq' ,width:'30'},{ title: '抗生素编码', field: 'antCode' },{ title: '抗生素名称', field: 'antName' }]" :aimKeys="[{ formKey: 'antNo', rowKey: 'antCode' },{ formKey: 'antNa', rowKey: 'antName' },{ formKey: 'potency', rowKey: 'verificationPrice' }]" :url="'/lis/bacAntibioticsDict/findAntDictList'" :dictTypeCode="'antClass'" @confirmClick="bacDrugResultConfirmClick" :isShowQuickCondition="false" />
                      </template>
                    </vxe-column>
                    <vxe-column field="potency1" title="血培养重量" width="100"></vxe-column>
                    <vxe-column field="potency2" title="培养结果(双击修改)" width="150"></vxe-column>
                    <vxe-column field="potency3" title="报阳时长" width="150"></vxe-column>
                    <vxe-column field="potency4" title="标本污染" width="150"></vxe-column>
                    <vxe-column field="potency5" title="形态描述" width="150"></vxe-column>
                    <vxe-column field="potency6" title="菌落计数" width="150"></vxe-column>
                    <vxe-column field="potency7" title="特殊描述" width="150"></vxe-column>
                    <vxe-column field="potency8" title="危急值" width="150"></vxe-column>
                    <vxe-column field="potency9" title="仪器" width="150"></vxe-column>
                    <vxe-column field="potency10" title="上机时间" width="150"></vxe-column>
                    <vxe-column field="potency11" title="结果时间" width="150"></vxe-column>
                    <vxe-column field="potency12" title="位置" width="150"></vxe-column>
                    <vxe-column field="potency13" title="状态" width="150"></vxe-column>
                    <vxe-column field="potency14" title="培养时间" width="150"></vxe-column>
                    <vxe-column field="potency15" title="培养瓶记录编号" width="150"></vxe-column>
                  </vxe-table>
                </div>
              </Pane>
              <Pane size="50">
                <div style="height: calc(100%)">
                  <vxe-table ref="bacDrugTestResultRef" height="auto" border show-overflow :header-cell-style="setBacDrugTestResultHeaderCellStyle" :data="bacDrugTestResult" :row-config="{ isCurrent: true }" :column-config="{ resizable: true }" :edit-config="{ trigger: 'click', mode: 'cell', showIcon: false }" @edit-closed="bacDrugTestResultEditClose">
                    <vxe-column type="seq" width="30"></vxe-column>
                    <vxe-column field="isReport" title="操作" align="center" :edit-render="{}" width="60">
                      <template #edit="{ row }">
                        <vxe-checkbox v-model="row.isReport" :checked-value="1" :unchecked-value="0"></vxe-checkbox>
                      </template>
                      <template #default="{ row }">
                        <vxe-checkbox v-model="row.isReport" :checked-value="1" :unchecked-value="0"></vxe-checkbox>
                      </template>
                    </vxe-column>
                    <vxe-column field="antRecomGroupNa" title="样本号" :edit-render="{ autofocus: '.vxe-input--inner' }" min-width="120px">
                      <template #default="{ row }">
                        <span>{{ row.antRecomGroupNa }}</span>
                      </template>
                      <template #edit="{ row }">
                        <vxe-input v-model="row.isReport" type="text"></vxe-input>
                      </template>
                    </vxe-column>
                    <vxe-column field="potency" title="检验目的" width="100"></vxe-column>
                    <vxe-column field="potency1" title="样本类型" width="150"></vxe-column>
                    <vxe-column field="potency2" title="报阳时长" width="150"></vxe-column>
                    <vxe-column field="potency3" title="一级报告" width="150"></vxe-column>
                    <vxe-column field="potency4" title="二级报告" width="150"></vxe-column>
                    <vxe-column field="potency5" title="三级报告" width="150"></vxe-column>
                  </vxe-table>
                </div>
              </Pane>
            </Splitpanes>
          </Pane>
          <Pane size="30">
            <div style="position:relative;height:100%;">
              <div class="padding-lr-xs ">
                <vxe-form ref="formObserRef" :data="formData" title-width="60">
                  <vxe-form-item title="仪器" field="name" span="24">
                    <template #default="params">
                      <vxe-input v-model="params.data.val1" placeholder="仪器" clearable></vxe-input>
                    </template>
                  </vxe-form-item>
                  <vxe-form-item title="瓶号" field="sex" span="12" :item-render="{}" title-overflow>
                    <template #default="params">
                      <vxe-input v-model="params.data.val2" placeholder="瓶号" clearable></vxe-input>
                    </template>
                  </vxe-form-item>
                  <vxe-form-item title="位置" field="sex" span="12" :item-render="{}" title-overflow>
                    <template #default="params">
                      <vxe-input v-model="params.data.val3" placeholder="位置" clearable></vxe-input>
                    </template>
                  </vxe-form-item>
                  <vxe-form-item title="上机时间" field="sex" span="12" :item-render="{}" title-overflow>
                    <template #default="params">
                      <vxe-input v-model="params.data.val2" placeholder="上机时间" clearable></vxe-input>
                    </template>
                  </vxe-form-item>
                  <vxe-form-item title="结果时间" field="sex" span="12" :item-render="{}" title-overflow>
                    <template #default="params">
                      <vxe-input v-model="params.data.val3" placeholder="结果时间" clearable></vxe-input>
                    </template>
                  </vxe-form-item>
                  <vxe-form-item title="状态" field="sex" span="12" :item-render="{}" title-overflow>
                    <template #default="params">
                      <vxe-input v-model="params.data.val2" placeholder="状态" clearable></vxe-input>
                    </template>
                  </vxe-form-item>
                  <vxe-form-item title="培养时间" field="sex" span="12" :item-render="{}" title-overflow>
                    <template #default="params">
                      <vxe-input v-model="params.data.val3" placeholder="培养时间" clearable></vxe-input>
                    </template>
                  </vxe-form-item>
                </vxe-form>
              </div>
              <div style="height:calc(100% - 120px - 35px)">
                <vxe-table border height="auto" align="center" :data="[{col0:'A',col1:'',col2:'',col3:'',col4:'',col5:'',col6:'',col7:'',col8:'',col9:'',col10:''},
              {col0:'B',col1:'',col2:'',col3:'',col4:'',col5:'',col6:'',col7:'',col8:'',col9:'',col10:''},
              {col0:'C',col1:'',col2:'',col3:'',col4:'',col5:'',col6:'',col7:'',col8:'',col9:'',col10:''},
              {col0:'D',col1:'',col2:'',col3:'',col4:'',col5:'',col6:'',col7:'',col8:'',col9:'',col10:''},
              {col0:'E',col1:'',col2:'',col3:'',col4:'',col5:'',col6:'',col7:'',col8:'',col9:'',col10:''},
              {col0:'F',col1:'',col2:'',col3:'',col4:'',col5:'',col6:'',col7:'',col8:'',col9:'',col10:''}]">
                  <vxe-column field="col0" title="行/列"></vxe-column>
                  <vxe-column field="col1" title="1"></vxe-column>
                  <vxe-column field="col2" title="2"></vxe-column>
                  <vxe-column field="col3" title="3"></vxe-column>
                  <vxe-column field="col4" title="4"></vxe-column>
                  <vxe-column field="col5" title="5"></vxe-column>
                  <vxe-column field="col6" title="6"></vxe-column>
                  <vxe-column field="col7" title="7"></vxe-column>
                  <vxe-column field="col8" title="8"></vxe-column>
                  <vxe-column field="col9" title="9"></vxe-column>
                  <vxe-column field="col10" title="10"></vxe-column>
                </vxe-table>
              </div>
              <div style="position:absolute;bottom:0px">
                <vxe-toolbar>
                  <template #buttons>
                    <div class="flex justify-end">
                      <vxe-button type="text" class="button-blue margin-lr-xs" :content="'在箱标本'"></vxe-button>
                    </div>
                  </template>
                </vxe-toolbar>
              </div>
            </div>
          </Pane>
        </Splitpanes>
      </Pane>
      <Pane :size="100-paneTopSize" :max-size="100-paneTopSize" :min-size="100-paneTopSize">
        <BacHistories ref="BacHistoriesRef" />
      </Pane>
    </Splitpanes>
    <BacProcessRecords ref="BacProcessRecordsRef" v-if="activeName === 'second'" />
    <Cost ref="costRef" v-show="activeName === 'fourth'" />

  </div>
</template>

<script setup lang="ts">
import { ref, reactive, computed, getCurrentInstance, defineProps } from 'vue';
import { Splitpanes, Pane } from 'splitpanes';
import { LabMainInfoBacBtns } from '../LabMainInfoBacUtils';
import { formatDateTime, IsEmpty } from '@/utils/common';
import VxePulldownSelectionByDictType from '@/components/VxePulldownSelectionByDictType.vue';
import { VxeMessage, VxeNotifyType } from '@/utils/CommonMessage';
import { VXETable, VxeFormPropTypes, VxeFormInstance } from 'vxe-table';
import { AppStore } from '@/stores/store';
import { SysOptions } from '@/stores/sysoptions';
import VxePulldownSelectionWithNa from '@/components/VxePulldownSelectionWithNa.vue';
import BacHistories from './BacHistories.vue';
import BacProcessRecords from './BacProcessRecords.vue';
import Cost from './Cost.vue';

defineExpose({
  initPage,
  initTestList,
  drugResultTempLdateQuickInsert,/**药敏模板快速输入 */
});

const storeObj = AppStore();
const sysoptionObj = SysOptions(); //系统参数状态管理对象
let { proxy }: any = getCurrentInstance();
const labmaininfobacbtns = ref(LabMainInfoBacBtns());
const bacTestResultRef = ref(null); /**细菌结果列表对象 */
const bacDrugTestResultRef = ref(null); /**药敏结果列表对象 */
const formObserRef: any = ref(null);/**菌落形态观察结果表单对象 */
const BacHistoriesRef = ref(null);/**多少天内结果组件对象 */
const BacProcessRecordsRef = ref(null);/**过程记录对象 */
let costRef: any = ref(null); //费用传值
let stepNodeObj: any = reactive({}); /**当前选中流程节点对象 */

const props = defineProps({
  tabs: {
    type: Array,
    default: reactive([
      {
        title: 'Step 1',
        iconSuccess: null,
        isValid: true
      },
      {
        title: 'Step 2',
        iconSuccess: null,
        isValid: true
      },
      {
        title: 'Step 3',
        iconSuccess: null,
        isValid: true
      }
    ])
  }
});
let layout: any[] = reactive([]);/**栅格布局数组 */
let bacActive = ref(3);/**当前选中第几珠菌 */
let formData: any = reactive({ val1: '', val2: '', val3: '', val4: '' });/**菌落形态观察结果表单 */
let isDescOptionResultFlag = ref(false);/**是否描述性结果 */
let labMainInfoObj: any = reactive({}); /**检验记录当前选中对象 */
let bacTestResultObj: any = reactive({}); /**细菌检验结果 */
let wkFlwNodeObj: any = reactive({}); /**工作流程节点对象 */
let bacTestResult: any[] = reactive([]); /**细菌检测结果列表 */
let bacDrugTestResult: any[] = reactive([]); /**细菌药敏检测结果 */
let form: any = reactive({
  autocalc: false
});
let activeName = ref('first');
let paneTopSize = ref(70);
let paneBottomSize = ref(30);
let curBacTestResult: any = reactive({});/**细菌鉴定结果列表行选中 */

//#region  计算属性
/**是否关闭初审按钮 */
let isVisiableFChkBtn = computed(() => {
  const a = sysoptionObj.globalOptions.filter((p: any) => p.field === 'ishidefirstchk');
  if (a && a.length > 0 && a[0] && !IsEmpty(a[0].value)) {
    return IsEmpty(a[0].value) ? false : a[0].value === '1' || a[0].value === 1 ? true : false;
  }
  return false;
});
/**病历按钮显示文字(等于-时隐藏) */
let dzblBtnText = computed(() => {
  const a = sysoptionObj.globalOptions.filter((p: any) => p.field === 'blbtntxt');
  if (a && a.length > 0 && a[0] && !IsEmpty(a[0].value)) {
    return IsEmpty(a[0].value) ? '' : a[0].value === '-' ? '' : a[0].value;
  }
  return '';
});
//#endregion

/**初始化界面 */
function initPage(mainInfoRow: any) {
  Object.assign(labMainInfoObj, mainInfoRow);
  findBacTestResult();
  getBacHistories();
}
//历史回顾传值
function getBacHistories() {
  BacHistoriesRef.value?.initPage(labMainInfoObj);
}


function tabHandleClick(tab) {
  if (tab.paneName === 'second') {
    BacProcessRecordsRef.value?.initRecords(labMainInfoObj, stepNodeObj);
  } else if (tab.paneName === 'fourth') {
    costRef.value.getreqDetail(labMainInfoObj);
  }
}

// 接收父组件传值
function initTestList(repData: any, isCbUptMainInfo = true) {
  if (IsEmpty(repData) || !repData) {
    resultList.length = 0;
    return;
  }
  Object.assign(labMainInfoObj, repData);
  findBacTestResult();
}

//上一个
function prevCLick() {
  actionCLick({ event: 'prevCode' });
}
//下一个
function nextCLick() {
  actionCLick({ event: 'nextCode' });
}

function actionCLick(item) {
  proxy.$emit('actionBtnsClick', item);
}
/**查询细菌检测结果 */
function findBacTestResult() {
  bacTestResult.length = 0;
  bacDrugTestResult.length = 0;

  if (IsEmpty(labMainInfoObj.id)) {
    return;
  }

  const url = '/api/bac/bac-test-result/findBacTestResultList';
  let data = { maininfoId: labMainInfoObj.id } as any;
  // if (!IsEmpty(wkFlwNodeObj.id)) {
  //   data['wkFlwId'] = wkFlwNodeObj.workFlowId;
  //   data['wkFlwNodeId'] = wkFlwNodeObj.id;
  // }

  proxy.$http
    .get(url, { params: data })
    .then((res: any) => {
      if (res && res.data && res.data.length >= 0) {
        bacTestResult.length = 0;
        Object.assign(bacTestResult, res.data);
        bacTestResultRef.value?.setCurrentRow(res.data[0]);
        findBacDrugTestResult(bacTestResult[0]);
      }
    })
    .catch((err: any) => { });
}

/**查询细菌检测结果 */
function findBacDrugTestResult(bacTestResult) {
  bacDrugTestResult.length = 0;
  if (IsEmpty(bacTestResult.id)) {
    return;
  }
  const url = '/api/bac/bac-drug-test-result/findBacDrugTestResultList';
  let data = { maininfoId: labMainInfoObj.id, bacTestResultId: bacTestResult.id } as any;
  proxy.$http
    .get(url, { params: data })
    .then((res: any) => {
      if (res && res.data && res.data.length >= 0) {
        bacDrugTestResult.length = 0;
        Object.assign(bacDrugTestResult, res.data);
        bacDrugTestResult.value?.setCurrentRow(res.data[0]);
      }
    })
    .catch((err: any) => { });
}
/**设置表头单元格样式 */
function setBacDrugTestResultHeaderCellStyle({ column }) {
  if (column.field === 'r' || column.field === 'i' || column.field === 'sdd' || column.field === 's' || column.field === 'ecoff' || column.field === 'whonetTest' || column.field === 'breakPointRef' || column.field === 'guideline' || column.field === 'year' || column.field === 'germCodeType' || column.field === 'orgCodeType' || column.field === 'germNo' || column.field === 'breakPointType' || column.field === 'host' || column.field === 'infeSite' || column.field === 'refTable' || column.field === 'refTableSeq' || column.field === 'breakPointId') {
    return { fontWeight: 300 };
  }
}
/** 细菌检测结果列表单元格样式*/
function setBacTestResultCellStyle({ row, column }) {
  if (column.field === 'wkFlwId') {
    return { backgroundColor: '#409eff', height: '100%' };
  }
  return null;
}
/**新增鉴定结果 */
async function insertBacTestResult(isDescOptionsResult = false) {
  if (IsEmpty(labMainInfoObj.sampleda) || IsEmpty(labMainInfoObj.rptGroup) || IsEmpty(labMainInfoObj.sampleNo) || IsEmpty(labMainInfoObj.id)) {
    VxeMessage('请先选中上机记录', VxeNotifyType.warning);
    return;
  }
  const userInfo = localStorage.getItem('userInfo');
  const userInfoObj = JSON.parse(userInfo);
  isDescOptionResultFlag.value = isDescOptionsResult;
  let row = {
    id: '',
    wkFlwId: '',
    isolateNum: null,
    germNo: '',
    germNa: '',
    testResult: '',
    resiPhenNa: '',
    urinColoCount: null,
    infeSiteNa: '',
    operateDate: formatDateTime(new Date(), 'yyyy-MM-dd hh:mm:ss'),
    operateUserNo: userInfoObj ? userInfoObj.realname : '',
    sampleda: formatDateTime(labMainInfoObj.sampleda, 'yyyy-MM-dd hh:mm:ss'),
    rptGroup: labMainInfoObj.rptGroup,
    sampleNo: labMainInfoObj.sampleNo,
    maininfoId: labMainInfoObj.id
  };
  bacTestResult.push(row);
  await bacTestResultRef.value?.setCurrentRow(row);
  await bacTestResultRef.value?.setEditCell(row, 'germNa');
  setTimeout(() => {
    bacTestResultRef.value?.scrollToRow(row);
  }, 100);
}
/**新增抗生素结果 */
async function insertBacDrugTestResult() {
  if (IsEmpty(curBacTestResult.id)) {

  }
  let row = {
    id: '',
    bacTestResultId: curBacTestResult.id,
    isReport: 0,
    wkFlwId: '',
    sampleda: formatDateTime(labMainInfoObj.sampleda, 'yyyy-MM-dd hh:mm:ss'),
    rptGroup: labMainInfoObj.rptGroup,
    sampleNo: labMainInfoObj.sampleNo,
    maininfoId: labMainInfoObj.id,
    antRecomGroupNa: '',
    antNo: '',
    antNa: '',
    potency: '',
    drugTestMethNa: '',
    testResult: '',
    interpNa: '',
    breakPoint: '',
    isNaturlResis: 0,
    r: '',
    i: '',
    sdd: '',
    s: '',
    ecoff: '',
    whonetTest: '',
    breakPointRef: '',
    guideline: '',
    year: '',
    germCodeType: '',
    germNo: '',
    breakPointType: '',
    host: '',
    infeSite: '',
    refTable: '',
    refTableSeq: '',
    breakPointId: '',
    isolateNum: null,
    germNa: '',
    testResult: '',
    resiPhenNa: '',
    urinColoCount: null,
    infeSiteNa: ''
  };
  bacDrugTestResult.push(row);
  await bacDrugTestResultRef.value?.setCurrentRow(row);
  await bacDrugTestResultRef.value?.setEditCell(row, 'antNa');
  setTimeout(() => {
    bacDrugTestResultRef.value?.scrollToRow(row);
  }, 100);
}
/**微生物结果选择确认事件 */
function bacTestResultConfirmClick(e) {
  if (e.isChild) {
    e.aimKeys.forEach((m) => {
      bacTestResult[e.childIndex][m.formKey] = e.row[m.rowKey];
    });
  }
}
/**描述性结果选择确认 */
function SelectRowClick(e) {
  if (e.isChild) {
    e.aimKeys.forEach((m) => {
      bacTestResult[e.childIndex][m.aimKey] = e.row[m.rowKey];
    });
  }
}
/**抗生素结果确认事件 */
function bacDrugResultConfirmClick(e) {
  if (e.isChild) {
    e.aimKeys.forEach((m) => {
      bacDrugTestResult[e.childIndex][m.formKey] = e.row[m.rowKey];
    });
  }
}
/**细菌结果列表关闭编辑状态 */
function bacTestResultEditClosed({ row, rowIndex, $rowIndex, column, columnIndex, $columnIndex }) {
  let url = `/api/bac/bac-test-result/${row && !IsEmpty(row.id) ? 'updateBacTestResult' : 'addBacTestResult'}`;
  proxy.$http
    .post(url, row)
    .then((res: any) => {
      Object.assign(bacTestResult[rowIndex], res.data);
    })
    .catch((err: any) => {
      //ToDo
    });
}
/**药敏鉴定结果列表关闭编辑状态 */
function bacDrugTestResultEditClose({ row, rowIndex, $rowIndex, column, columnIndex, $columnIndex }) {
  let url = `/api/bac/bac-drug-test-result/${row && !IsEmpty(row.id) ? 'updateBacDrugTestResult' : 'addBacDrugTestResult'}`;
  proxy.$http
    .post(url, row)
    .then((res: any) => {
      Object.assign(bacDrugTestResult[rowIndex], res.data);
    })
    .catch((err: any) => {
      //ToDo
    });
}
/**细菌列表行选择改变 */
function bacTestResultSelectChange({ row }) {
  Object.assign(curBacTestResult, row);
  bacDrugTestResult.length = 0;
  findBacDrugTestResult(curBacTestResult);
}
/**药敏鉴定结果 刷新按钮刷新 */
function bacDrugTestResultRefresh() {
  findBacDrugTestResult(curBacTestResult);
}
/**删除细菌鉴定结果 */
async function deletebacTestResult() {
  const row = bacTestResultRef.value?.getCurrentRecord();
  if (IsEmpty(row) || IsEmpty(row.id)) {
    VxeMessage('请先选中要删除的行', VxeNotifyType.warning);
    return;
  }
  const type = await VXETable.modal.confirm('确定删除选中记录?'); /*不能改el  $confirm 回车事件冒泡你*/
  if (type === 'confirm') {
    let url = `/api/bac/bac-test-result/deleteBacTestResult`;
    proxy.$http
      .post(url, row)
      .then(async (res: any) => {
        if (res && res.status && !IsEmpty(res.status.code) && res.status.code === 1) {
          const ci = bacTestResultRef.value?.getRowIndex(row);
          await bacTestResultRef.value?.remove(row);
          bacTestResult.splice(ci, 1);
          VxeMessage(res.status.msg, VxeNotifyType.success);
        } else {
          VxeMessage(res.status.msg, VxeNotifyType.error);
        }
      })
      .catch((err: any) => {
        VxeMessage('删除失败', VxeNotifyType.error);
      });
  }
}
/**删除药敏检验结果 */
async function deleteBacDrugTestResult() {
  const row = bacDrugTestResultRef.value?.getCurrentRecord();
  if (IsEmpty(row) || IsEmpty(row.id)) {
    VxeMessage('请先选中要删除的行', VxeNotifyType.warning);
    return;
  }
  const type = await VXETable.modal.confirm('确定删除选中记录?'); /*不能改el  $confirm 回车事件冒泡你*/
  if (type === 'confirm') {
    let url = `/api/bac/bac-drug-test-result/deleteBacDrugTestResult`;
    proxy.$http
      .post(url, row)
      .then(async (res: any) => {
        if (res && res.status && !IsEmpty(res.status.code) && res.status.code === 1) {
          const ci = bacDrugTestResultRef.value?.getRowIndex(row);
          await bacDrugTestResultRef.value?.remove(row);
          bacDrugTestResult.splice(ci, 1);
          VxeMessage(res.status.msg, VxeNotifyType.success);
        } else {
          VxeMessage(res.status.msg, VxeNotifyType.error);
        }
      })
      .catch((err: any) => {
        VxeMessage('删除失败', VxeNotifyType.error);
      });
  }
}
/**选择药敏模板 */
function insertBacDrugResultTemplate() {
  proxy.$emit('selectBacDrugResultTemplate');
}
/**药敏模板快速输入 */
function drugResultTempLdateQuickInsert(rows) {
  const curTestResultObj = bacTestResultRef.value?.getCurrentRecord();
  let url = `/api/bac/bac-drug-test-result/drugResultTemplateQuickInsert`;
  proxy.$http
    .post(url, { mainInfoId: labMainInfoObj.id, bacTestResultId: curTestResultObj.id, bacDrugResultTemplates: rows })
    .then(async (res: any) => {
      if (res && res.status && !IsEmpty(res.status.code) && res.status.code === 1) {
        findBacDrugTestResult(curTestResultObj);
        VxeMessage(res.status.msg, VxeNotifyType.success);
      } else {
        VxeMessage(res.status.msg, VxeNotifyType.error);
      }
    })
    .catch((err: any) => {
      VxeMessage('删除失败', VxeNotifyType.error);
    });
}
/**批量删除药敏结果 */
async function deleteAll() {
  const type = await VXETable.modal.confirm('确定全部删除记录?'); /*不能改el  $confirm 回车事件冒泡你*/
  if (type === 'confirm') {
    let url = `/api/bac/bac-drug-test-result/batchDeleteBacDrugTestResult`;
    proxy.$http
      .post(url, bacDrugTestResult)
      .then((res: any) => {
        if (res && res.status && !IsEmpty(res.status.code) && res.status.code === 1) {
          const curTestResultObj = bacTestResultRef.value?.getCurrentRecord();
          findBacDrugTestResult(curTestResultObj);
          VxeMessage(res.status.msg, VxeNotifyType.success);
        } else {
          VxeMessage(res.status.msg, VxeNotifyType.error);
        }
      })
      .catch((err: any) => {
        VxeMessage('删除失败', VxeNotifyType.error);
      });
  }
}
</script>

<style scoped lang="scss">
@import '@/assets/css/el-tabs.scss';

#bacTestResult {
  height: 100%;
}

.lab-bac-test-result-tab {
  :deep(.el-tabs__header) {
    margin-bottom: 0;
  }

  :deep(.el-tabs__nav-prev) {
    line-height: 28px !important;
  }

  :deep(.el-tabs__nav-next) {
    line-height: 28px !important;
  }

  :deep(.el-tabs__content) {
    height: 0px;
    padding: 2px;
  }

  :deep(.el-tab-pane) {
    height: 0px;
  }
}
:deep(.cell-bgColor) {
  .vxe-cell {
    height: 100%;
  }
}
</style>
